home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1999 Macromedia, Inc. All rights reserved.
-
- //*************** GLOBALS VARS *****************
-
- //******************* API **********************
-
- //***************** LOCAL FUNCTIONS ******************
-
- function initialize() {
- MM.event.handled = clearObject();
- window.close();
- }
-
-
- function clearObject() {
- var docDOM, attainDOM, theSel, fullSrc, retVal = false;
-
- // get the source
- docDOM = dw.getDocumentDOM();
- theSel = docDOM.getSelection();
- fullSrc = getSelectedSrc(theSel);
-
- if (fullSrc.search(/<interaction/gi) == -1 &&
- fullSrc.search(/<\/interaction>/gi) == -1) {
- return retVal;
- }
-
- // make selection valid
- theSel = makeValidSelection(theSel);
- fullSrc = getSelectedSrc(theSel);
-
- if (fullSrc.search(/<interaction/gi) == -1 &&
- fullSrc.search(/<\/interaction>/gi) == -1) {
- return retVal;
- }
-
- if (!regCheck()) {
- return retVal;
- }
-
- setBusyCursor();
-
- setNewline(); //init NEWLINE global
-
- // create the dom objects
- attainDOM = new AttainDOM();
-
- // remove the source
- dw.deleteSelection();
- attainDOM.removeSrc(fullSrc);
- retVal = true;
-
- clearBusyCursor();
-
- garbageCollect(true);
-
- return retVal;
- }
-
-
- function makeValidSelection(theSel) {
- var docDOM, objList, attainSel, newSel = '';
- docDOM = dw.getDocumentDOM();
- objList = getAttainObjs();
- for (var i=0; !newSel && i < objList.length; i++) {
- attainSel = docDOM.nodeToOffsets(objList[i]);
- if (theSel[0] < attainSel[0] &&
- theSel[1] > attainSel[0] && theSel[1] < attainSel[1])
- newSel = new Array(theSel[0], attainSel[0]);
- if (theSel[1] > attainSel[1] &&
- theSel[0] > attainSel[0] && theSel[0] < attainSel[1])
- newSel = new Array(attainSel[1], theSel[1]);
- }
- if (newSel) {
- docDOM.setSelection(newSel[0], newSel[1]);
- return newSel;
- } else {
- return theSel;
- }
- }
-